import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: 'dashboard', icon: 'homePage', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/parkingResources',
    component: Layout,
    redirect: 'parkingResources',
    name: 'parkingResources',
    children: [{
      path: '',
      component: _import('parkingResources/index'),
      name: 'parkingResources',
      meta: { title: 'parkingResources', icon: 'parkingResources', noCache: true }
    }]
  },
  {
    path: '/resourceCollection',
    component: Layout,
    redirect: 'noredirect',
    name: 'resourceCollection',
    alwaysShow: true,
    meta: {
      title: 'resourceCollection',
      icon: 'resourceCollection',
      roles: ['540000']
    },
    children: [
      { path: 'parkInformation', component: _import('resourceCollection/parkInformation'), name: 'parkInformation', meta: { title: 'parkInformation', noCache: true, roles: ['110400'] }},
      // { path: 'resourceMap', component: _import('resourceCollection/resourceMap'), name: 'resourceMap', meta: { title: 'resourceMap', noCache: true, roles: ['110400'] }},
      { path: 'dataReport', component: _import('resourceCollection/dataReport'), name: 'dataReport', meta: { title: 'dataReport', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/parkDataSearch',
    component: Layout,
    redirect: 'parkDataSearch',
    name: 'parkDataSearch',
    alwaysShow: true,
    meta: {
      title: 'parkDataSearch',
      icon: 'parkDataSearch',
      roles: ['540000']
    },
    children: [
      { path: 'parkInfoDataSearch', component: _import('parkDataSearch/parkInfoDataSearch'), name: 'parkInfoDataSearch', meta: { title: 'parkInfoDataSearch', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/aidDecision',
    component: Layout,
    redirect: 'aidDecision',
    name: 'aidDecision',
    alwaysShow: true,
    meta: {
      title: 'aidDecision',
      icon: 'aidDecision',
      roles: ['540000']
    },
    children: [
      { path: 'parkAnalysis', component: _import('aidDecision/parkAnalysis'), name: 'parkAnalysis', meta: { title: 'parkAnalysis', noCache: true, roles: ['110400'] }},
    ]
  },
  {
    path: '/inducedRelease',
    component: Layout,
    redirect: 'noredirect',
    name: 'inducedRelease',
    alwaysShow: true,
    meta: {
      title: 'inducedRelease',
      icon: 'inducedRelease',
      roles: ['540000']
    },
    children: [
      { path: 'inducementTime', component: _import('inducedRelease/inducementTime'), name: 'inducementTime', meta: { title: 'inducementTime', noCache: true, roles: ['110400'] }},
      { path: 'induceInfo', component: _import('inducedRelease/induceInfo'), name: 'induceInfo', meta: { title: 'induceInfo', noCache: true, roles: ['110400'] }},
      { path: 'induceGroup', component: _import('inducedRelease/induceGroup'), name: 'induceGroup', meta: { title: 'induceGroup', noCache: true, roles: ['110400'] }},
      { path: 'inducedLog', component: _import('inducedRelease/inducedLog'), name: 'inducedLog', meta: { title: 'inducedLog', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/comprehensive',
    component: Layout,
    redirect: 'noredirect',
    name: 'comprehensive',
    alwaysShow: true,
    meta: {
      title: 'comprehensive',
      icon: 'comprehensive',
      roles: ['540000']
    },
    children: [
      { path: 'illegalParking', component: _import('comprehensive/illegalParking'), name: 'illegalParking', meta: { title: 'illegalParking', noCache: true, roles: ['110400'] }},
      { path: 'trackManagement', component: _import('comprehensive/trackManagement'), name: 'trackManagement', meta: { title: 'trackManagement', noCache: true, roles: ['110400'] }},
      { path: 'trackFeatures', component: _import('comprehensive/trackFeatures'), name: 'trackFeatures', meta: { title: 'trackFeatures', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/deviceManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'deviceManagement',
    alwaysShow: true,
    meta: {
      title: 'deviceManagement',
      icon: 'deviceManagement',
      roles: ['540000']
    },
    children: [
      { path: 'management', component: _import('deviceManagement/management'), name: 'management', meta: { title: 'management', noCache: true, roles: ['110400'] }},
      { path: 'maintenanceManagement', component: _import('deviceManagement/maintenanceManagement'), name: 'maintenanceManagement', meta: { title: 'maintenanceManagement', noCache: true, roles: ['110400'] }},
      { path: 'maintenanceStatistics', component: _import('deviceManagement/maintenanceStatistics'), name: 'maintenanceStatistics', meta: { title: 'maintenanceStatistics', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/suggestions',
    component: Layout,
    redirect: 'noredirect',
    name: 'suggestions',
    alwaysShow: true,
    meta: {
      title: 'suggestions',
      icon: 'suggestions',
      roles: ['540000']
    },
    children: [
      { path: 'suspectedViolation', component: _import('suggestions/suspectedViolation'), name: 'suspectedViolation', meta: { title: 'suspectedViolation', noCache: true, roles: ['110400'] }},
      { path: 'hotSuggestion', component: _import('suggestions/hotSuggestion'), name: 'hotSuggestion', meta: { title: 'hotSuggestion', noCache: true, roles: ['110400'] }},
      { path: 'word', component: _import('suggestions/word'), name: 'word', meta: { title: 'word', noCache: true, roles: ['110400'] }}
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
